
import { Component, OnInit, Input } from '@angular/core';
import { User } from '../../models/user';
import { Router } from '@angular/router';
import { UserService } from '../../services/user.service';
import {isDefined} from '@angular/compiler/src/util';
import {MenuService} from '../../services/menu.service';

@Component ({
  selector: 'app-menu-aside',
  styleUrls: ['./menu-aside.component.css'],
  templateUrl: './menu-aside.component.html'
})
export class MenuAsideComponent implements OnInit {
  public currentUrl: string;
  public currentUser: User = new User();

  @Input() links: Array<any> = [];
  @Input() display_menu_user = true;
  @Input() display_menu_search = true;

  constructor(
    private userServ: UserService,
    public router: Router,
    private menuServ:MenuService
  ) {
    // getting the current url
    this.router.events.subscribe((evt: any) => {
      this.currentUrl = evt.url;
      
    });
    this.userServ.getCurrent().subscribe((user) => this.currentUser = user);
    
  }

  public ngOnInit() {
    this.menuServ.setCurrent(this.links)
  }

  
}
